<?php
	App::import("Model","Config.BaseConfig");
	class SmfConfig extends BaseConfig
	{
		var $name = "SmfConfig";
		var $cache  = "+30 minutes";
		var $fieldProperties = array(
			'forum_path'=>array('label'=>"Forum Path","type"=>"text",'group'=>'add','validate'=>array("rule"=>"checkForumPath",'message'=>"Please enter a valid path",'allowEmpty'=>false,'required'=>true),'toopltip'=>"Directoy path of forum"),
			'forum_url'=> array("label"=>"Forum URL",'type'=>"text",'group'=>'add'),
		);
		
		function checkForumPath($data)
		{
			$path = $data['forum_path'];
			$path = realpath($path);
			$settingFile = $path.DS.'Settings.php';
			$error = false;
			if(!is_dir($path))
			{
				$error = "Path is not a valid directory";
			}else if(!is_readable($path))
			{
				$error = "Path is not readable";
			}else if(!file_exists($settingFile))
			{
				$error = "No Settings.php file found in the directory.Please confirm this is a Simple Machine forum setup";
			}
			if($error == false)
			{
				return true;
			}
			return $error;
		}
	}
?>